package com.demo.decorate;

/**
 * @author gy
 * @date 2022/4/5
 */
public class BufferReader_ {
    private Reader_ reader_;

    // 此处可以传入任意 Reader的子类，实现了增强
    public BufferReader_(Reader_ reader_) {
        this.reader_ = reader_;
    }

    public void selfFileReader(){
        reader_.fileReader();
    }

    public void selfStringReader(){
        reader_.stringReader();
    }

    /**
     *     让方法更加灵活,同时对方法进行了加强
      */
    public void enhanceFilesReader(int num){
        for (int i = 0; i < num; i++) {
            reader_.fileReader();
        }
    }

    /**
     *     让方法更加灵活,同时对方法进行了加强
      */
    public void enhanceStringsReader(int num){
        for (int i = 0; i < num; i++) {
            reader_.stringReader();
        }
    }
}
